<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #text {
            border: 1px solid #000;
            height: 400px;
            overflow: scroll;
        }
    </style>
</head>
<body>
<input type="button" id="btn" value="过滤所有属性">
<input type="button" id="btn1" value="过滤行间样式">
<input type="button" id="btn2" value="过滤html标签">
<div contenteditable="true" id="text">请输入内容...</div>
<script>
    var oBtn = document.getElementById("btn");
    var oBtn1 = document.getElementById("btn1");
    var oBtn2 = document.getElementById("btn2");
    var oText = document.getElementById("text");
    oBtn.onclick = function () {
        oText.innerHTML = oText.innerHTML.replace(/<([a-zA-Z]+)\s*[^><]*>/g, "<$1>");
    }
    oBtn1.onclick = function () {
        oText.innerHTML = oText.innerHTML.replace(/style="[^"]+"|height="[^"]+"|width="[^"]+"/ig, "");
    }
    oBtn2.onclick = function () {
        oText.innerHTML = oText.innerHTML.replace(/<[^>]+>/g, "");
    }
    oText.onfocus = function () {
        if (this.innerHTML == "请输入内容...") {
            this.innerHTML = "";
        }
    }
    oText.onblur = function () {
        if (this.innerHTML == "") {
            this.innerHTML = "请输入内容...";
        }
    }
</script>

</body>
</html>